<template>
	<view class="loginBox">
		<img class="logo" src="@/static/logo.jpg" alt="" />
		<view class="title">
			登录
		</view>
		<view class="inpBox">
			<u-input class="inp" v-model="email" placeholder='请输入手机号码' />
			<u-input class="inp" type='password' v-model="password" placeholder='请输入密码' />
		</view>
		<view class="forget" @click="forgetFn">
			忘记密码？
		</view>
		<view class="btns">
			<u-button class="btn" @click="login">立即登录</u-button>
		</view>
		<view class="tips">
			还没有账号？<span class="reg" @click="goRegister">立即注册</span>
		</view>
	</view>

</template>

<script>
	import {
		login
	} from "@/api/index.js"
	export default {
		data() {
			return {
				email: '',
				password: ''
			}
		},
		onLoad() {

		},
		methods: {
			login() {
				let params = {
					account: this.email,
					password: this.password
				}
				login(params).then(res => {
					if (res.code == 1) {
						uni.setStorageSync('token', res.data.userinfo.token)

						uni.setStorageSync('subjectType', 1)
						uni.switchTab({
							url: '/pages/index/index',

						})
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				})
			},
			goRegister() {
				uni.navigateTo({
					url: "/pages/register/register"
				})
			},
			forgetFn() {
				uni.navigateTo({
					url: '../register/editPassword'
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.loginBox {
		padding: 0 64rpx;
		padding-top: 92rpx;

		.logo {
			margin: 0 auto;
			width: 120rpx;
			border-radius: 100%;
			padding: 10rpx;
			display: block;
		}

		.title {
			font-family: Alimama ShuHeiTi;
			font-size: 40rpx;
			font-weight: 700;
			line-height: 56rpx;
			letter-spacing: 0rpx;
			text-align: left;
			color: #262626;
			margin-top: 34rpx;

			.title2 {
				font-family: PingFang SC;
				font-size: 26rpx;
				font-weight: 400;
				line-height: 36rpx;
				letter-spacing: 0rpx;
				text-align: left;
				color: #8C8C8C;
				margin-top: 16rpx;

			}
		}

		.inpBox {
			margin-top: 56rpx;

			.inp {
				background: #F7F8FA;
				padding: 16rpx 56rpx !important;
				margin-bottom: 24rpx;
				border-radius: 16rpx;
			}
		}

		.forget {
			color: #FA430E;
			font-family: PingFang SC;
			font-size: 26rpx;
			font-weight: 400;
			line-height: 36rpx;
			letter-spacing: 0rpx;
			text-align: left;
			text-decoration: underline;
		}

		.btns {
			margin-top: 88rpx;

			.btn {
				font-size: 32rpx;
				color: #fff;
				background: #FE430E !important;
				border-radius: 16rpx;
			}
		}

		.tips {
			color: #8C8C8C;
			font-size: 26rpx;
			text-align: center;
			margin-top: 28rpx;

			.reg {
				color: #FA430E;
			}
		}
	}
</style>